from celery import Celery
from app.celery_task.config import (
    broker_url, result_backend, timezone,
    task_serializer, result_serializer, accept_content,
    task_track_started, task_time_limit, result_expires,
    worker_pool_restarts, worker_max_tasks_per_child,
    pool_options, broker_connection_retry_on_startup
)

app = Celery(
    'exhibition_tasks',
    broker=broker_url,
    backend=result_backend,
    include=['app.celery_task.tasks']
)

# 配置
app.conf.update(
    # 基本配置
    broker_connection_retry_on_startup=broker_connection_retry_on_startup,
    
    # 时区配置
    timezone=timezone,
    
    # 序列化配置
    task_serializer=task_serializer,
    result_serializer=result_serializer,
    accept_content=accept_content,
    
    # 任务配置
    task_track_started=task_track_started,
    task_time_limit=task_time_limit,
    result_expires=result_expires,
    
    # Windows特定配置
    worker_pool_restarts=worker_pool_restarts,
    worker_max_tasks_per_child=worker_max_tasks_per_child,
    pool_options=pool_options
)
 